package exception;

import java.io.FileOutputStream;
import java.io.IOException;

public class FinallyDemo2 {
    public static void main(String[] args) {
        FileOutputStream fos = null;

        try {
            fos = new FileOutputStream("fos.txt");
            fos.write(99);
        } catch (IOException e) {
            System.out.println("出错了");
        } finally {
            if(fos != null){
                try {
                    fos.close();
                } catch (IOException e) {
                    System.out.println("文件关闭出错了");
                }
            }
        }
    }
}
